import React, { Component } from 'react'
import { Input, Button, Table, Tag, Popconfirm, message } from 'antd'
import back from './index.module.css'
import getday from '../../util/getday'
export default class BlackList extends Component {
    state = {
        list: [],
        columns: [
            {
                title: '编号',
                dataIndex: 'userid',
                key: 'userid',
                render: (value, item, key) => {
                    return key + 1
                }
            },
            {
                title: '用户姓名',
                dataIndex: 'name',
                key: 'name',
            },
            {
                title: '是否初始密码',
                dataIndex: 'pwd',
                key: 'pwd',
            }, {
                title: '创建日期',
                dataIndex: 'createTime',
                key: 'createTime',
                render: (value) => {
                    return getday(value * 1)
                }
            }
        ],
        userName: ''
    }
    componentDidMount() {
        this.newList()
    }
    // 更新数据
    newList = () => {
        this.$httpReq(this.$api.blackUserList(), res => {

            this.setState({ list: res.data })
        })
    }
    // 解除冻结
    confirm = userid => {
        console.log(userid)
        this.$httpReq(this.$api.blackUserIco({ userid }), res => {
            message.success('已启用');
            this.newList()
        })
    }
    cancel = () => {
        message.error('已取消');
    }
    //检索userName
    search = () => {
        const { userName } = this.state

        let obj = {
            name: userName
        }
        this.$httpReq(this.$api.searchBlackUserList(obj), res => {
            this.setState({ list: res.data })
            this.setState({ userName: '' })
        })
    }
    render() {
        const { columns, list, userName } = this.state
        return <div>
            <div className={back.b_top}>
                <span>姓名检索</span>
                <Input placeholder="请输入关键字" value={userName} onChange={e => this.setState({ userName: e.target.value })} />
            </div>
            <div className={back.b_button}>
                <Button type="primary" onClick={() => this.search()}>搜索</Button>
            </div>
            <Table pagination={{ pageSize: 6 }} dataSource={list} columns={columns} rowKey={item => item.key} />
        </div>
    }
}



